package cn.com.cabinet.manager.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cabinet.web.entity.Order;
import com.cabinet.web.entity.Seller;

import cn.com.cabinet.dao.SellerDao;
import cn.com.cabinet.manager.dto.OrderDto;
import cn.com.cabinet.util.JsonUtil;
import cn.com.easy.dto.PageRequestParamDTO;

@Controller
@RequestMapping("/manager/seller")
public class SellerController {
	
	@Autowired
	private SellerDao sellerDao;
	
	@RequestMapping("/index")
	public String index(){
		return "/Seller/index";
		
	}
	
	@RequestMapping("/list")
	public void getSellerList(Integer key, Integer status,PageRequestParamDTO paramDto,HttpServletRequest req, HttpServletResponse res) throws IOException{
		int thispage = (paramDto.getPageNumber()-1)*10;
		PrintWriter pw = res.getWriter(); 
		List<Seller> oList = sellerDao.getSellerApplication(status, thispage, paramDto.getPageSize());
		int total = sellerDao.getSellerApplicationCount(status).size();
		String sellRecordJson = JsonUtil.parseJson(oList);
		String json = "{\"total\":" + total + ",\"rows\":" + sellRecordJson + "}";
		pw.print(json);
	}

}
